home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / contacts / buddyinfo.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  3KB  |  79 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from common import profile
  5. from logging import getLogger
  6. log = getLogger('buddyinfo')
  7.  
  8. class BuddyInfo(object):
  9.     __slots__ = [
  10.         'protocol_name',
  11.         'protocol_username',
  12.         'buddy_name']
  13.     
  14.     def __init__(self, buddy):
  15.         protocol = buddy.protocol
  16.         self.protocol_name = protocol.name
  17.         self.protocol_username = protocol.username
  18.         self.buddy_name = buddy.name
  19.  
  20.     
  21.     def __eq__(self, obj):
  22.         s = object()
  23.         for slot in self.__slots__:
  24.             if getattr(self, slot) != getattr(obj, slot, s):
  25.                 return False
  26.                 continue
  27.         
  28.         return True
  29.  
  30.     
  31.     def __hash__(self):
  32.         return hash(('_'.join,)((lambda .0: for slot in .0:
  33. getattr(self, slot))(self.__slots__)))
  34.  
  35.     
  36.     def buddy(self):
  37.         protocol = profile.account_manager.get_im_account(self.protocol_username, self.protocol_name)
  38.         if protocol is None or not (protocol.connected):
  39.             return None
  40.         
  41.         return protocol.connection.get_buddy(self.buddy_name)
  42.  
  43.     
  44.     def isbuddy(self, buddy):
  45.         if buddy.name == self.buddy_name and buddy.protocol.username == self.protocol_username:
  46.             pass
  47.         return buddy.protocol.name == self.protocol_name
  48.  
  49.     
  50.     def __repr__(self):
  51.         return '<BuddyInfo %s (on %s:%s)>' % (self.buddy_name, self.protocol_name, self.protocol_username)
  52.  
  53.  
  54.  
  55. class binfoproperty(object):
  56.     
  57.     def __init__(self, name, default = sentinel):
  58.         if not isinstance(name, basestring):
  59.             raise TypeError
  60.         
  61.         self.name = name
  62.         self.default = default
  63.  
  64.     
  65.     def __get__(self, obj, objtype):
  66.         res = profile.blist.get_contact_info(obj, self.name)
  67.         if res is None and self.default is not sentinel:
  68.             res = self.default()
  69.             log.info('%s: %s not found, placing default %s', obj.name, self.name, res)
  70.             profile.blist.set_contact_info(obj, self.name, res)
  71.         
  72.         return res
  73.  
  74.     
  75.     def __set__(self, obj, value):
  76.         return profile.blist.set_contact_info(obj, self.name, value)
  77.  
  78.  
  79.